#include <iostream>
#include <vector>
using namespace std;
class Solution
{
public:
    vector<int> countBits(int n)
    {
        vector<int> res(0);
        for (int i = 0; i <= n; i++)
        {
            int t = i, count = 0;
            while (t)
            {
                count += t & 1;
                t >>= 1;
            }
            res.push_back(count);
        }
        return res;
    }
};